//
//  BuyCarDetailTopCell.m
//  New_Runway
//
//  Created by mack on 2018/2/13.
//  Copyright © 2018年 NelsonJ. All rights reserved.
//

#import "BuyCarDetailTopCell.h"

@interface BuyCarDetailTopCell ()
@property (weak, nonatomic) IBOutlet UILabel *carName;
@property (weak, nonatomic) IBOutlet UILabel *priceL;
@property (weak, nonatomic) IBOutlet UILabel *newcarPrice;
@property (weak, nonatomic) IBOutlet UILabel *timeAndDistance;
//@property (weak, nonatomic) IBOutlet UILabel *carNum;
//@property (weak, nonatomic) IBOutlet UILabel *libraryAge;
@property (weak, nonatomic) IBOutlet UIImageView *typeImage;
@property (weak, nonatomic) IBOutlet UIImageView *Authentication;
//@property (weak, nonatomic) IBOutlet UIButton *saleType;
//@property (weak, nonatomic) IBOutlet UIButton *lookNum;
//@property (weak, nonatomic) IBOutlet UIImageView *authenticationIm;
@property (copy, nonatomic)  NSString *traFee;
@property (copy, nonatomic)  NSString *oneprice;
//@property (weak, nonatomic) IBOutlet UILabel *subName;
@property (weak, nonatomic) IBOutlet UIButton *financeServes;
@property (weak, nonatomic) IBOutlet UIButton *extendedServes;
@property (weak, nonatomic) IBOutlet UILabel *isTranAndPrice;
@end

@implementation BuyCarDetailTopCell

-(void)setCarInfo:(CarResult *)carInfo{
    _carInfo = carInfo;
    self.carName.text = carInfo.carTitle;
    //已预订 1 未预定0
    if (carInfo.carOrderState == 1) {
        self.typeImage.hidden = NO;
    }else{
        self.typeImage.hidden = YES;
        
    }
 
    //特价车 1是0不是
    if (carInfo.carRetailPrice <= 0) {
        self.priceL.text =  @"价格面议";
        
    }else{
        self.priceL.text =  [NSString stringWithFormat:@"¥ %.2f万",(CGFloat)carInfo.carRetailPrice];
    }
    self.newcarPrice.text = [NSString stringWithFormat:@"(%@)",carInfo.shop.shopName];
//    self.carNum.text = [NSString stringWithFormat:@"车架号： %@",carInfo.carVin];
//    if (carInfo.stockAgeRemark) {
//        self.libraryAge.text = [NSString stringWithFormat:@"库龄： %@",carInfo.stockAgeRemark];
//    }else{
//        self.libraryAge.text = @"库龄：";
//
//    }
    NSString *carSctockStr = @"";
    if (carInfo.carStockState == 0) {
        carSctockStr = @"未完成入库";
    }else if (carInfo.carStockState == 10){
        carSctockStr = @"入库审核";
    }else if (carInfo.carStockState == 20){
        carSctockStr = @"已入库";
    }else if (carInfo.carStockState == 30){
        carSctockStr = @"出库审核";
    }else if (carInfo.carStockState == 40){
        carSctockStr = @"已出库";
    }else{
        carSctockStr = @"--";
    }
    if (_carInfo.carTransferState == 0) {
        self.traFee = @"不含过户费";
        
    }else{
        self.traFee = @"含过户费";
        
    }
    if (_carInfo.carFixedPriceState == 0) {
        self.oneprice = @"不是一口价";
    }else{
        self.oneprice = @"一口价";
    }
    self.isTranAndPrice.text = [NSString stringWithFormat:@"%@ | %@",self.traFee, self.oneprice];
    NSString *mileageStr;
    if ([carInfo.carMileage doubleValue] <= 0) {
        mileageStr = @"未输入里程";
    }else{
        if ([carInfo.carMileage doubleValue] < 0.1) {
            mileageStr = [NSString stringWithFormat:@"%.f公里", [carInfo.carMileage doubleValue] *10000];
            
        }else{
            mileageStr = [NSString stringWithFormat:@"%.2f万公里", [carInfo.carMileage doubleValue]];
            
        }
        
    }
    if (carInfo.carLicenceState == 1 ) {
        self.timeAndDistance.text = [NSString stringWithFormat:@"%@ | %@",[NRWCarTurnTime timestampSwitchTime:carInfo.carLicenceDate andFormatter:@"yyyy年MM月"],mileageStr];

    }else if (carInfo.carLicenceState == 2){
        self.timeAndDistance.text = [NSString stringWithFormat:@"未上牌 | %@",mileageStr];

    }else if (carInfo.carLicenceState == 3){
        self.timeAndDistance.text = [NSString stringWithFormat:@"新车 | %@",mileageStr];
    }
  
    
    if (carInfo.carFinanceService == 1) {
        self.financeServes.hidden = NO;
    }else{
        self.financeServes.hidden = YES;
        
    }
    if (carInfo.carExtendedWarranty == 1) {
        self.extendedServes.hidden = NO;
    }else{
        self.extendedServes.hidden = YES;
        
    }
    
    if (self.carInfo.carAuthState == 10) {
        self.Authentication.hidden = NO;
    }else{
        self.Authentication.hidden = YES;

    }
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
